//
//  CommonFullScreenVideoCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/9/25.
//  Copyright © 2020 王洋. All rights reserved.
//
#import <SDWebImage/SDWebImage.h>

#import "CommonFullScreenVideoCell.h"

@implementation CommonFullScreenVideoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)fillCellWithModel:(CommonMediaModel *)model {
    
    self.model = model;
    __block UIImage *placeholderImage = [UIImage imageNamed:@"placeholder"];
    WEAKSELF
    [[SDImageCache sharedImageCache] diskImageExistsWithKey:self.model.videoCover completion:^(BOOL isInCache) {
        __typeof(&*weakSelf) strongSelf = weakSelf;
        if (isInCache) {
            //本地存在图片,替换占位图片
            placeholderImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:model.videoCover];
        }
        [strongSelf.coverImageView sd_setImageWithURL:[NSURL URLWithString:model.videoCover] placeholderImage:placeholderImage];
    }];
}

- (IBAction)playAction:(id)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(cl_commonTableViewCellPlayVideoWithCell:)]){
        [_delegate cl_commonTableViewCellPlayVideoWithCell:self];
    }
}

@end
